100 '
105 '>>>>> Trivia Master Program
110 '
115 '>>>>> by Randy Hawkins
120 '
130 COMMON RH: IF RH=0 THEN SYSTEM
140 CLEAR: ON ERROR GOTO 1410
150 DIM P(73,6),ID(73),X(8),Y(8),X2(8),Y2(8),PN$(6),TC$(7),AN(6,7),W(6): WIDTH 80: COLOR 14,1,1: SCREEN 0: CLS: KEY OFF: TT=60
160 COLOR 4,4: FOR A=1 TO 23: LOCATE A,1: PRINT "  ";: LOCATE A,79: PRINT "  ";: NEXT A: FOR A=1 TO 80: LOCATE 1,A: PRINT " ";: LOCATE 3,A: PRINT " ";: LOCATE 8,A: PRINT " ";: LOCATE 23,A: PRINT " ";: NEXT A: COLOR 14,1
170 LOCATE 2,27: PRINT "T R I V I A   M A S T E R";: LOCATE 4,3: PRINT "This program will assist you and as many as five of your friends as you play";: LOCATE 5,3: PRINT "Trivial Pursuit (tm Selchow and Righter Company) or any similar trivia game.";
180 LOCATE 6,3: PRINT "The computer will keep track of your position on the board, keep scores for";: LOCATE 7,3: PRINT "all players, and display a timer to force you to answer within"; TT; "seconds.";
190 RANDOMIZE TIMER: DEF FNR(X)=INT(RND*6)+1: FOR A=1 TO 73: FOR B=1 TO 6: READ P(A,B): NEXT B: READ ID(A): NEXT A
192 KEY (17) ON: KEY 17, CHR$(0)+CHR$(1): ON KEY (17) GOSUB 1400
194 KEY (18) ON: KEY 18, CHR$(32)+CHR$(1): ON KEY (18) GOSUB 1400
196 KEY (19) ON: KEY 19, CHR$(64)+CHR$(1): ON KEY (19) GOSUB 1400
200 LOCATE 10,3,1: PRINT "How many are playing (2-6)? ";: DEF SEG=0: POKE 1050,PEEK(1052)
210 A$=INKEY$: IF A$<"2" OR A$>"6" THEN 210 ELSE NP=VAL(A$): PRINT A$
220 FOR A=1 TO NP: LOCATE 11+A,3: PRINT "What is player #"; CHR$(48+A); "'s name";
230 INPUT PN$(A): W(A)=1: AN(A,7)=1: FOR B=1 TO 6: AN(A,B)=0: NEXT B,A
240 FOR A=10 TO 11+NP: LOCATE A,3: PRINT STRING$(70,32);: NEXT A
250 LOCATE 10,3: PRINT "Enter a description for each of": LOCATE 11,3: PRINT "the six categories of trivia below:"
260 FOR A=1 TO 6: LOCATE 12+A,3: PRINT "Trivia Category #"; CHR$(48+A);: INPUT TC$(A): NEXT A: TC$(7)="Roll Again": PL=1
270 WIDTH 40: COLOR 14,1,1: CLS: LOCATE 2,1,0: PRINT PN$(PL); "'s Turn": LOCATE 2,37: PRINT "You": LOCATE 3,36: PRINT"Need:": LOCATE 4,1: PRINT CHR$(201); STRING$(3,205); CHR$(203); STRING$(30,205); CHR$(203); STRING$(3,205); CHR$(187);
280 FOR A=0 TO 12 STEP 2: LOCATE 5+A,1: PRINT CHR$(186); CHR$(32); CHR$(49+A/2); CHR$(32); CHR$(186); CHR$(32); LEFT$(TC$(1+A/2),28); TAB(36); CHR$(186); MID$(CHR$(17)+"--   ",AN(PL,A/2+1)*3+1,3); CHR$(186);
290 LOCATE 6+A,1: PRINT CHR$(204); STRING$(3,205); CHR$(206); STRING$(30,205); CHR$(206); STRING$(3,205); CHR$(185);: NEXT A
300 LOCATE 18,1: PRINT CHR$(200); STRING$(3,205); CHR$(202); STRING$(30,205); CHR$(202); STRING$(3,205); CHR$(188);
310 AN(PL,0)=0: FOR A=1 TO 7: AN(PL,0) = AN(PL,0) + AN(PL,A): NEXT A: IF AN(PL,0)<7 THEN LOCATE 21,12: COLOR 18,0: PRINT " One Moment Please ";: COLOR 14,1
320 IF AN(PL,0)=7 THEN A$ = PN$(PL) + " has answered questions": LOCATE 21,21-LEN(A$)/2: PRINT A$: LOCATE 22,4: PRINT "from all 6 categories and might be": LOCATE 23,4: PRINT "able to win the game on this turn!"
330 D=FNR(6): P=W(PL): GOSUB 490: IF AN(PL,0)=7 AND X(1)=1 THEN 480 ELSE FOR A=1 TO 7: Y(A)=0: NEXT A: IF X(1)=1 THEN FOR A=1 TO 6: Y(A)=1: NEXT A ELSE FOR A=1 TO Z: Y(ID(X(A)))=1: NEXT A
340 FOR A=1 TO 7:IF Y(A)=0 THEN FOR B=LEN(TC$(A)) TO 0 STEP -1: LOCATE 3+A*2,7: PRINT RIGHT$(TC$(A),B);" ";: SOUND 300+A*200+B*25,1: NEXT B
350 NEXT A: LOCATE 21,1: PRINT STRING$(120,32);: A$ = PN$(PL) + ", press the number": LOCATE 21,21-LEN(A$)/2: PRINT A$: LOCATE 22,5: PRINT "of the category you have selected": DEF SEG=0: POKE 1050,PEEK(1052)
360 A$=INKEY$: IF A$<"1" OR A$>"7" THEN 360 ELSE C=VAL(A$): IF Y(C)=0 THEN 360 ELSE IF C=7 THEN 270 ELSE A=1
370 IF ID(X(A))=C OR X(A)=1 THEN W(PL)=X(A) ELSE A=A+1: GOTO 370
380 CLS: A$="Please ask "+PN$(PL): LOCATE 4,21-LEN(A$)/2: PRINT A$: LOCATE 5,12: PRINT "a question from the": A$=CHR$(34)+TC$(C)+CHR$(34)+" Category": LOCATE 6,21-LEN(A$)/2: PRINT A$
390 LOCATE 8,5: PRINT "After the question has been read,": LOCATE 9,4: PRINT "press <ANY KEY> to start the clock.": DEF SEG=0: POKE 1050,PEEK(1052):WHILE INKEY$="": WEND
400 LOCATE 8,1: PRINT STRING$(80,32): LOCATE 16,5: PRINT "Press  R  if the answer is right": LOCATE 18,5: PRINT "Press  W  if the answer is wrong": COLOR 20,0: LOCATE 16,11: PRINT" R ": LOCATE 18,11: PRINT" W ": COLOR 14,1: LOCATE 9,14
410 PRINT"Time Remaining:": COLOR 2,0: LOCATE 11,18: PRINT "      ": LOCATE 12,18: PRINT USING" #.## ";INT(TT/60)+(TT-INT(TT/60)*60)/100;: LOCATE 12,20: PRINT":";: LOCATE 13,18: PRINT"      ": DEF SEG=0: POKE 1050,PEEK(1052): A=TIMER: B=TT
420 A$=INKEY$: IF INSTR(" RrWw",A$)>1 THEN 430 ELSE IF TIMER-A<1 THEN 420 ELSE B=B-1: LOCATE 12,19: PRINT USING"#.##";INT(B/60)+(B-INT(B/60)*60)/100;: LOCATE 12,20: PRINT ":";: SOUND 100,.1: A=TIMER: IF B>0 THEN 420 ELSE SOUND 100,10: A$="W"
430 COLOR 14,1: LOCATE 16,1: PRINT STRING$(120,32): IF A$="R" OR A$="r" THEN A$="right.": B=1 ELSE A$="wrong.": B=0
440 A$=PN$(PL)+"'s answer was "+A$: LOCATE 16,21-LEN(A$)/2: PRINT A$: LOCATE 18,10: PRINT "Is that correct (Y/N)?": DEF SEG=0: POKE 1050,PEEK(1052)
450 A$=INKEY$: IF A$="N" OR A$="n" THEN A$=CHR$(82+B*5): GOTO 430 ELSE IF A$<>"Y" AND A$<>"y" THEN 450
460 IF B=0 THEN PL=PL+1+(PL=NP)*NP: GOTO 270
470 AN(PL,C)=1: IF AN(PL,0)<7 OR W(PL)<>1 THEN 270 ELSE WIDTH 80: COLOR 14,1,1: CLS: WORD$=PN$(PL): LN=1: GOSUB 1300: WORD$="wins the": LN=2: GOSUB 1300: WORD$="game!": LN=3: GOSUB 1300: WHILE INKEY$="": WEND: GOTO 1400
480 CLS: A$="To win the game, "+PN$(PL)+" must answer": LOCATE 4,21-LEN(A$)/2: PRINT A$: LOCATE 5,7: PRINT "one question from a category": LOCATE 6,5: PRINT "selected by the other player(s).": W(PL)=1: GOTO 390
490 Z=0: FOR A=1 TO 6: Y(A)=10: Q=P(P,A): IF Q THEN Z=Z+1: X(Z)=Q: Y(Z)=A
500 GOSUB 560: NEXT A: IF D=1 THEN 540
510 FOR C=2 TO D: Z2=0: FOR A=1 TO Z: FOR B=1 TO 6: IF ABS(B-Y(A))=3 THEN 530
520 Q=P(X(A),B): IF Q THEN Z2=Z2+1: X2(Z2)=Q: Y2(Z2)=B
530 GOSUB 560: NEXT B,A: Z=Z2: FOR A=1 TO Z: X(A)=X2(A): Y(A)=Y2(A): NEXT A,C
540 FOR A=1 TO Z-1: FOR B=A+1 TO Z: IF X(A)>X(B) THEN SWAP X(A),X(B)
550 GOSUB 560: NEXT B,A: RETURN
560 IF FNR(6)<6 THEN RETURN ELSE SOUND RND*1000+50,1: RETURN
570 DATA 3,4,5,6,7,2,0
580 DATA 0,0,1,0,0,8,2
590 DATA 9,0,0,1,0,0,3
600 DATA 0,10,0,0,1,0,5
610 DATA 0,0,11,0,0,1,4
620 DATA 1,0,0,12,0,0,1
630 DATA 0,1,0,0,13,0,6
640 DATA 0,0,2,0,0,14,5
650 DATA 15,0,0,3,0,0,4
660 DATA 0,16,0,0,4,0,1
670 DATA 0,0,17,0,0,5,6
680 DATA 6,0,0,18,0,0,2
690 DATA 0,7,0,0,19,0,3
700 DATA 0,0,8,0,0,20,4
710 DATA 21,0,0,9,0,0,1
720 DATA 0,22,0,0,10,0,6
730 DATA 0,0,23,0,0,11,2
740 DATA 12,0,0,24,0,0,3
750 DATA 0,13,0,0,25,0,5
760 DATA 0,0,14,0,0,26,6
770 DATA 27,0,0,15,0,0,2
780 DATA 0,28,0,0,16,0,3
790 DATA 0,0,29,0,0,17,5
800 DATA 18,0,0,30,0,0,4
810 DATA 0,19,0,0,31,0,1
820 DATA 0,0,20,0,0,32,1
830 DATA 33,0,0,21,0,0,6
840 DATA 0,34,0,0,22,0,2
850 DATA 0,0,35,0,0,23,3
860 DATA 24,0,0,36,0,0,5
870 DATA 0,25,0,0,37,0,4
880 DATA 0,38,26,49,0,0,3
890 DATA 0,0,39,27,44,0,5
900 DATA 0,0,0,40,28,45,4
910 DATA 46,0,0,0,41,29,1
920 DATA 30,47,0,0,0,42,6
930 DATA 43,31,48,0,0,0,2
940 DATA 0,50,0,0,32,0,1
950 DATA 0,0,51,0,0,33,6
960 DATA 34,0,0,52,0,0,2
970 DATA 0,35,0,0,53,0,3
980 DATA 0,0,36,0,0,54,5
990 DATA 55,0,0,37,0,0,4
1000 DATA 0,33,0,0,56,0,6
1010 DATA 0,0,34,0,0,57,2
1020 DATA 58,0,0,35,0,0,3
1030 DATA 0,59,0,0,36,0,5
1040 DATA 0,0,60,0,0,37,4
1050 DATA 32,0,0,61,0,0,1
1060 DATA 0,62,0,0,38,0,7
1070 DATA 0,0,63,0,0,39,7
1080 DATA 40,0,0,64,0,0,7
1090 DATA 0,41,0,0,65,0,7
1100 DATA 0,0,42,0,0,66,7
1110 DATA 67,0,0,43,0,0,7
1120 DATA 0,44,0,0,68,0,7
1130 DATA 0,0,45,0,0,69,7
1140 DATA 70,0,0,46,0,0,7
1150 DATA 0,71,0,0,47,0,7
1160 DATA 0,0,72,0,0,48,7
1170 DATA 49,0,0,73,0,0,7
1180 DATA 0,68,0,0,50,0,4
1190 DATA 0,0,69,0,0,51,1
1200 DATA 52,0,0,70,0,0,6
1210 DATA 0,53,0,0,71,0,2
1220 DATA 0,0,54,0,0,72,3
1230 DATA 73,0,0,55,0,0,5
1240 DATA 0,56,0,0,62,0,2
1250 DATA 0,0,57,0,0,63,3
1260 DATA 64,0,0,58,0,0,5
1270 DATA 0,65,0,0,59,0,4
1280 DATA 0,0,66,0,0,60,1
1290 DATA 61,0,0,67,0,0,6
1300 DEF SEG=65446!: FOR X=0 TO 7: LOCATE LN*8+X-7,41-LEN(WORD$)*4,0: FOR Y=1 TO LEN(WORD$): Q=PEEK(ASC(MID$(WORD$,Y,1))*8+X+14)
1310 IF Q=0 THEN PRINT STRING$(8,32); ELSE FOR Z=7 TO 0 STEP -1: PRINT CHR$(32+187*SGN(Q AND 2^Z));: NEXT Z
1320 NEXT Y,X: RETURN
1400 WIDTH 80: COLOR 2,0,0: CLS: LOCATE 12,28: PRINT "One moment please...": RUN "menu"
1410 RESUME NEXT
